// testCalendarClass.cpp

using namespace std;

#include "../Calendar.h"

int main(int argc, char *argv[]) {
  cout << "Test parser" << endl;
  const char *title = argv[0];
  if (argc <= 1) {
    cout << "usage:" << endl
         << title << " <vcardfilename>" << endl;
    return 0;
  }

  const char *fname = argv[1];

  if (access(fname, 0) != 0) {
    cout << "unable to access <" << fname << ">" << endl;
    return -1;
  };

  // test loading
  Calendar t1;
  Calendar::createFromFile(&t1, * new string(argv[1]));

  ///////////////////////////////////////////////    
  //now get some of those values
  ///////////////////////////////////////////////    

  // start and end times
  time_t current;
  time(&current);
  time_t end;
  struct tm * tempTM = localtime(&current);
  tempTM->tm_mday+=7; // one week later
  end = mktime(tempTM);

  // now get all the items in the range and print some of their data
  set<Item, Item>* items = new set<Item, Item>;
  t1.getItemsForPeriod(items, current, end);
  set<Item, Item>::iterator it;

  cout << items << endl;

  for(it = items->begin(); it != items->end(); ++it)
    cout << *it << endl;

  //////////////////////////////////////////////    

  // done
  cout << "Done." << endl;

  return 0;
}
